package com.iqik.sharding.hint;

import org.apache.shardingsphere.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.hint.HintShardingValue;

import java.util.ArrayList;
import java.util.Collection;

public class MyHintShardingAlgorithm implements HintShardingAlgorithm<Long> {
    @Override
    public Collection<String> doSharding(
            Collection<String> collection,
            HintShardingValue<Long> hintShardingValue) {
        Collection<String> result = new ArrayList<>();
        for (String each: collection) {
            System.out.println(each);
            for (Long value: hintShardingValue.getValues()) {
                System.out.println(value);
                if (each.endsWith(String.valueOf(value % 2))) {
                    System.out.println("endsWith: " + value);
                    result.add(each);
                }
            }
        }
        return null;
    }
}
